Passed
Push — master ( 57e849...66e16b )
by Michael
02:16
created

MenuPlugin.js ➔ MenuPlugin   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 1
c 0
b 0
f 0
cc 1
nop 1
rs 10
1
import { Plugin } from 'prosemirror-state';
2
import MenuView from './MenuView';
3
4
/**
5
 * Create a new menu plugin from the given items
6
 *
7
 * @param {[MenuItem]} items The items tp be displayed in the menu
8
 *
9
 * @return {Plugin} a new Prosemirror Plugin
10
 *
11
 * @constructor
12
 */
13
function MenuPlugin(items) {
14
    return new Plugin({
15
        view(editorView) {
16
            const menuView = new MenuView(items, editorView);
17
            editorView.dom.parentNode.insertBefore(menuView.dom, editorView.dom);
18
            return menuView;
19
        },
20
    });
21
}
22
23
export default MenuPlugin;
24